package com.huawei.hms.support.api.iap.json;

import android.text.TextUtils;
import com.huawei.hms.common.internal.ResponseErrorCode;
import com.huawei.hms.common.internal.TaskApiCall;
import com.huawei.hms.support.api.client.Status;
import com.huawei.hms.support.api.entity.iap.ConsumePurchaseResp;
import com.huawei.hms.support.api.iap.ConsumePurchaseResult;
import com.huawei.hms.support.hianalytics.HiAnalyticsClient;
import com.huawei.hms.support.log.HMSLog;
import com.huawei.hms.utils.JsonUtil;
import o.fjx;

public class ConsumePurchaseTaskApiCall extends TaskApiCall<IapHmsClient, ConsumePurchaseResult> {
    public ConsumePurchaseTaskApiCall(String str, String str2, String str3) {
        super(str, str2, str3);
    }

    protected void doExecute(IapHmsClient iapHmsClient, ResponseErrorCode responseErrorCode, String str, fjx<ConsumePurchaseResult> o_fjx_com_huawei_hms_support_api_iap_ConsumePurchaseResult) {
        if (responseErrorCode == null) {
            o_fjx_com_huawei_hms_support_api_iap_ConsumePurchaseResult.ॱ(new IapApiException(new Status(1)));
            return;
        }
        HiAnalyticsClient.reportExit(iapHmsClient.getContext(), getUri(), getTransactionId(), responseErrorCode.getStatusCode(), responseErrorCode.getErrorCode());
        if (TextUtils.isEmpty(str)) {
            o_fjx_com_huawei_hms_support_api_iap_ConsumePurchaseResult.ॱ(new IapApiException(new Status(responseErrorCode.getErrorCode(), responseErrorCode.getErrorReason())));
        } else if (responseErrorCode.getErrorCode() == 0) {
            HMSLog.i("ConsumePurchaseTaskApiCall", "onResult, success");
            ConsumePurchaseResp consumePurchaseResp = new ConsumePurchaseResp();
            JsonUtil.jsonToEntity(str, consumePurchaseResp);
            ConsumePurchaseResult consumePurchaseResult = new ConsumePurchaseResult();
            consumePurchaseResult.setReturnCode(consumePurchaseResp.getReturnCode());
            consumePurchaseResult.setErrMsg(consumePurchaseResp.getErrMsg());
            consumePurchaseResult.setConsumePurchaseData(consumePurchaseResp.getConsumePurchaseData());
            consumePurchaseResult.setDataSignature(consumePurchaseResp.getDataSignature());
            consumePurchaseResult.setStatus(new Status(responseErrorCode.getStatusCode(), responseErrorCode.getErrorReason()));
            o_fjx_com_huawei_hms_support_api_iap_ConsumePurchaseResult.ॱ(consumePurchaseResult);
        } else {
            HMSLog.i("ConsumePurchaseTaskApiCall", "onResult, returnCode: " + responseErrorCode.getErrorCode());
            o_fjx_com_huawei_hms_support_api_iap_ConsumePurchaseResult.ॱ(new IapApiException(new Status(responseErrorCode.getErrorCode(), responseErrorCode.getErrorReason())));
        }
    }
}
